﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cn.Edwon.Biz;
using Cn.Edwon.Spring;
using Cn.Edwon.Web.Support;
using Cn.Cellula.Client.ControlHelper;
using Cn.Cellula.Module.Stat.Model;
using Cn.Cellula.Client;
using Cn.Edwon.Web;
using System.Data;
using Cn.Cellula.Module.Stat.FusionCharts;
using System.Text;
using System.Collections;
using Cn.Edwon.Util;
using Common.Logging;
using System.Reflection;
using Cn.Edwon.Data;

namespace Cn.Cellula.Website.Admin.Module.Stat {
    public partial class Default : PageSupport {
        IBiz biz = BizFactory.Get<IBiz>();
        public String StatKey = "";
        public String ChartFileName = "";
        IList<CallingParameter> _params = new List<CallingParameter>();
        protected void Page_Load(object sender, EventArgs e) {
            if (!Page.IsPostBack) {
                LoadStatList();
            }
        }
        private void LoadStatList() {
            IList<ModTStatEO> list = biz.LoadAll<ModTStatEO>();
            if (list != null && list.Count > 0) {
                this.gvList.DataSource = list;
                this.gvList.DataBind();
                String key = Request.QueryString["id"];
                if (String.IsNullOrEmpty(key)) {
                    key = list[0].StatKey;
                }
                GvHelper.GvSelected(ref this.gvList, key, null);
                LoadStat(key);
            } else {
                SiteInfo.Send(Page, TxtDef.INFO, "尚未制定统计报表");
                return;
            }
            
        }
        private void LoadStat(String key) {
            ModVStatEO eo = biz.Load<ModVStatEO>(key);
            StatKey = eo.StatKey;
            ChartFileName = eo.ChartFileName;
            this.hid_StatKey.Value = eo.StatKey;
            this.lab_StatName.Text = eo.StatName;
        }
    }
}